package utility

import "github.com/google/uuid"
import "encoding/hex"

func GetUuid() string {
	uuidV4, err :=uuid.NewRandom()
	if err != nil {
		panic(err.Error())
	}

	var buf [36]byte
	encodeHex(buf[:], uuidV4)
	return string(buf[:])
}

func encodeHex(dst []byte, uuid uuid.UUID) {
	hex.Encode(dst[:], uuid[:4])
	dst[8] = '-'
	hex.Encode(dst[9:13], uuid[4:6])
	dst[13] = '-'
	hex.Encode(dst[14:18], uuid[6:8])
	dst[18] = '-'
	hex.Encode(dst[19:23], uuid[8:10])
	dst[23] = '-'
	hex.Encode(dst[24:], uuid[10:])
}
